package com.wsh.controller;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wsh.service.UserService;
import com.wsh.vo.User;

@Controller
@RequestMapping("/user")
public class UserController {
	@Autowired
	private UserService userService;
	
	@RequestMapping("/logon")
	public @ResponseBody int logon(String name,String pwd,HttpSession session){
		int i=0;
		User user=userService.queryUser(name);
		if(user!=null){
			if(user.getWangpan_pwd().equals(pwd)){
				i=1;
				session.setAttribute("name", name);
				session.setAttribute("uid", user.getWangpan_uid());
			}else{
				i=2;
			}
			
		}
		return i;
		
	}

}
